//package com.travel.travelServer.service1.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.github.pagehelper.PageHelper;
//import com.github.pagehelper.PageInfo;
//import com.travel.travelServer.entity1.Comment;
//import com.travel.travelServer.entity1.Landscapes;
//import com.travel.travelServer.entity1.vo.CommentVo;
//import com.travel.travelServer.mapper1.CommentMapper;
//import com.travel.travelServer.mapper1.LandscapesMapper;
//import com.travel.travelServer.service1.CommentService;
//import com.travel.travelServer.utils.BaseService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Arrays;
//import java.util.Date;
//import java.util.List;
//
//@Service
//public class CommentServiceImpl extends BaseService<CommentMapper, Comment> implements CommentService {
//
//    @Autowired
//    CommentMapper commentMapper;
//
//    @Autowired
//    LandscapesMapper landscapesMapper;
//
//    /**
//     * 新增Comment
//     *
//     * @param commentVo
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int insertComment(CommentVo commentVo) {
//        Date date = new Date();
//        commentVo.setCreateTime(date);
//        commentVo.setUpdateTime(date);
//        commentVo.setCreateBy("admin");
//        commentVo.setUpdateBy("admin");
//        commentVo.setUserId(getCurrentUser().getId());
//        commentMapper.insert(commentVo);
//        return 1;
//    }
//
//    /**
//     * 单个删除Comment信息
//     *
//     * @param id-主键
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int deleteById(Long id) {
//        return commentMapper.deleteById(id);
//    }
//
//    /**
//     * 批量删除Comment信息
//     *
//     * @param ids-主键[]
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int deleteByIds(Long[] ids) {
//        return commentMapper.deleteBatchIds(Arrays.asList(ids));
//    }
//
//    /**
//     * 修改Comment
//     *
//     * @param commentVo
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int updateComment(CommentVo commentVo) {
//        commentMapper.updateById(commentVo);
////        LambdaQueryWrapper<CommentMenu> wrapper = new LambdaQueryWrapper<>();
////        wrapper.eq(CommentMenu::getCommentId, commentVo.getId());
////        commentMenuMapper.delete(wrapper);
////        List<Long> menuIds = commentVo.getMenuIds();
////        if (menuIds.size() > 0){
////            for (Long menuId : menuIds) {
////                CommentMenu commentMenu = new CommentMenu();
////                commentMenu.setCommentId(commentVo.getId());
////                commentMenu.setMenuId(menuId);
////                commentMenuMapper.insert(commentMenu);
////            }
////        }
//        return 1;
//    }
//
//    /**
//     * 查询Comment
//     *
//     * @param id-主键
//     * @return comment
//     */
//    @Override
//    public Comment selectById(Long id) {
//        return commentMapper.selectById(id);
//    }
//
//    /**
//     * 查询Comment列表
//     *
//     * @param commentVo
//     * @return Comment集合
//     */
//    @Override
//    public List<Landscapes> selectCommentList(CommentVo commentVo) {
//        List<Landscapes> landscapes = landscapesMapper.selectList(null);
//        for (Landscapes landscape : landscapes) {
//            LambdaQueryWrapper<Comment> commentWrapper = new LambdaQueryWrapper<>();
//            commentWrapper.eq(Comment::getLandscapesId, landscape.getId());
//            List<Comment> comments = commentMapper.selectList(commentWrapper);
//            landscape.setComments(comments);
//        }
//        return landscapes;
//    }
//
//    @Override
//    public PageInfo<Comment> getInfoPage(CommentVo commentVo) {
//        // 使用 PageHelper 分页
//        PageHelper.startPage(commentVo.getPageNum(), commentVo.getPageSize());
//        LambdaQueryWrapper<Comment> wrapper = new LambdaQueryWrapper<>();
//        wrapper.like(Comment::getContent, commentVo.getContent());
//        List<Comment> comments = commentMapper.selectList(wrapper);
//        return new PageInfo<>(comments);
//    }
//
//}
